package Exercise;

public class Student implements Comparable<Student>{
    private String name;
    private int age;
    private int ChineseScore;
    private int MathScore;
    private int EnglishScore;
    public Student(){

    }

    public Student(String name, int age, int chineseScore, int mathScore, int englishScore) {
        this.name = name;
        this.age = age;
        ChineseScore = chineseScore;
        MathScore = mathScore;
        EnglishScore = englishScore;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getChineseScore() {
        return ChineseScore;
    }

    public void setChineseScore(int chineseScore) {
        ChineseScore = chineseScore;
    }

    public int getMathScore() {
        return MathScore;
    }

    public void setMathScore(int mathScore) {
        MathScore = mathScore;
    }

    public int getEnglishScore() {
        return EnglishScore;
    }

    public void setEnglishScore(int englishScore) {
        EnglishScore = englishScore;
    }

    @Override
    public int compareTo(Student o) {
        int sum1 = this.getChineseScore()+this.getEnglishScore()+this.getMathScore();
        int sum2 = o.getChineseScore()+o.getEnglishScore()+o.getMathScore();
        int i = sum1 - sum2;
        i = i==0?this.getChineseScore()-o.getChineseScore():i;
        i = i==0?this.getMathScore()-o.getMathScore():i;
        i = i==0?this.getEnglishScore()-o.getEnglishScore():i;
        i = i==0?this.getAge()-o.getAge():i;
        i = i==0?this.getName().compareTo(o.getName()):i;
        return i;
    }
}
